package com.wondersgroup.fjzlpt.org.service.impl.zdgl;

import java.util.Map;

import com.quick.framework.exception.ServiceException;
import com.quick.framework.util.LoggerUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.remoteResult.ResultObject;
import com.wondersgroup.fjzlpt.org.dao.inter.zdgl.ZdglDAO;
import com.wondersgroup.fjzlpt.org.service.inter.zdgl.ZdglService;


@Service
public class ZdglServiceImpl implements ZdglService{

	@Autowired
	private ZdglDAO zdglDAO;
	
	/**
	 * 分页查询服务项
	 * @param map
	 * @return
	 */
	//@Cacheable("queryPage")
	public JSONObject queryPage(Map<String, String> map) {
		return zdglDAO.queryPage(map);
	}
	
	/**
	 * 删除字典表目录
	 * @param map
	 * @return
	 */
	public JSONObject delete(Map<String, String> map) {
		ResultObject ro = new ResultObject();
		try {
			zdglDAO.deleteForPrimaryKey(map);
		} catch (Exception e) {
			LoggerUtil.error(e.getMessage());
			throw new ServiceException("ERR-001001","删除字典表目录失败！");
		}
		return (JSONObject)JSON.toJSON(ro);
	}

	/**
	 * 新增字典表目录
	 * @param map
	 * @return
	 */
	public JSONObject insert(Map<String, String> map) {
		ResultObject ro = new ResultObject();
		try {
			zdglDAO.insert(map);
		} catch (Exception e) {
			LoggerUtil.error(e.getMessage());
			throw new ServiceException("ERR-001002","新增字典表目录失败！");
		}
		return (JSONObject)JSON.toJSON(ro);
	}
}
